<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = ['a', 'a', 'a', 'b', 'b', 'c', 'c', 'c', 'c', 'd', 'd', 'd', 'd']
        // { a: 3, b: 2, c: 4, d: 4 }
        let obj = {}
        arr.map(item => {
            if (obj[item]) {
                obj[item] += 1
            } else {
                obj[item] = 1
            }
        })
        console.log(obj);
    </script>
</body>

</html>